import 'package:boss/ui/widget/custom_divier.dart';
import 'package:hi_common/hi_common.dart';
import 'package:flutter/material.dart';

class ColumnDivier extends StatelessWidget {
  final List<Widget> children;
  final EdgeInsets padding;
  final MainAxisAlignment mainAxisAlignment;
  final CrossAxisAlignment crossAxisAlignment;
  final bool itemPadding;

  const ColumnDivier({
    Key key,
    this.children,
    this.padding,
    this.mainAxisAlignment = MainAxisAlignment.center,
    this.crossAxisAlignment = CrossAxisAlignment.start,
    this.itemPadding,
  }) : super(key: key);

  @override
  Widget build(BuildContext context) {
    List<Widget> children = [];

    this.children.forEach((item) {
      Widget child = item;

      if (padding != null) {
        child = Padding(
          padding: padding,
          child: child,
        );
      }

      children.add(child);

      if (item != this.children.last)
        children.add(CustomDivider(
          height: itemPadding == true ? 0 : 20.w,
        ));
    });

    return Column(
      mainAxisAlignment: mainAxisAlignment,
      crossAxisAlignment: crossAxisAlignment,
      children: children,
    );
  }
}
